package main

import (
	"database/sql"
	"fmt"
	_ "github.com/go-sql-driver/mysql"
)

func main() {
	db, err := sql.Open("mysql", "root:root@tcp(10.205.86.49:3306)/nlpc_stat?charset=utf8")
	if err != nil {
		panic("sql.Open failed")
		panic(err.Error())
	}
	defer db.Close()
	rows, err := db.Query("select id, timestamp, total, succ from tb_entity_linking_drpc order by id desc limit 10;")
	if err != nil {
		panic(err.Error())
	}
	defer rows.Close()
	var id int
	var timestamp string
	var total int
	var succ int
	for rows.Next() {
		err := rows.Scan(&id, &timestamp, &total, &succ)
		fmt.Printf("id:%d\ttimestamp:%s\ttotal:%d\tsucc:%s", id, timestamp, total, succ)
		if err != nil {
			panic(err.Error())
		}
	}
}
